from flask import Flask
from flask_mail import Message

from prompting.mail_config import mail_config, mail, sender
from prompting.timing_task import task
from route.index import remind

app = Flask(__name__)

# 配置邮件
mail_config(app)

# 定时任务配置 开启
task(app)

# 路由配置
app.add_url_rule("/", view_func=remind)


# 发送邮件
def send_mail(title, recipients, message):
    msg = Message(title, sender=sender, recipients=recipients)
    msg.body = message
    with app.app_context():
        mail.send(msg)


if __name__ == "__main__":
    app.run(host="0.0.0.0", port=80)
